
 /**
 * RoleManagerImpl.java.java.
 * User: BrianChen Date: 2012-6-8 下午03:23:50
 *
 * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
 * All rights reserved.
 */
package com.collapsar.core.security.service.impl;

import com.collapsar.core.security.dao.IRoleDao;
import com.collapsar.core.security.dao.IUserDao;
import com.collapsar.core.security.model.Role;
import com.collapsar.core.security.service.IRoleManager;
import com.collapsar.core.service.BaseUserAwareManager;

/**
 * <pre>
 * REVISIONS: 
 * Version 	Date 		Author 			Description
 * ------------------------------------------------------------------- 
 * 1.0 		2012-6-8 	BrianChen 	1. Created this class. 
 * </pre>
 * 
 * @author BrianChen
 * @date 2012-6-8 下午03:23:50
 * @version 1.0
 * @see
 * 
 */
public class RoleManagerImpl extends BaseUserAwareManager implements IRoleManager{
	
	private IRoleDao roleDao = null;
	private IUserDao userDao = null;
	
	@Override
	public void storeRole(Role role) {
		this.roleDao.storeRole(role);
	}

	@Override
	public void deleteRole(Role role) {
		this.roleDao.deleteRole(role);
	}

	@Override
	public void deleteAllRoles(Long[] roleIds) {
		this.roleDao.deleteAllRoles(roleIds);
	}

	@Override
	public Role loadRole(Long roleId) {
		return this.roleDao.loadRole(roleId);
	}

	@Override
	public Role loadRoleWithUsers(Long roleId) {
		return this.loadRoleWithUsers(roleId);
	}

	@Override
	public Role getRoleByName(String roleName) {
		return this.roleDao.getRoleByName(roleName);
	}

//	@Override
//	public void addUsers(Long[] userIds, Long roleId) {
//		Role role = this.loadRoleWithUsers(roleId);
//		for(Long userId : userIds){
//			role.addUser(this.userDao.loadUser(userId));
//		}
//		this.roleDao.storeRole(role);
//	}
//
//	@Override
//	public void deleteUsers(Long[] userIds, Long roleId) {
//		Role role = this.loadRoleWithUsers(roleId);
//		for(Long userId : userIds){
//			role.deleteUser(this.userDao.loadUser(userId));
//		}
//		this.roleDao.storeRole(role);
//	}

	public IRoleDao getRoleDao() {
		return roleDao;
	}

	public void setRoleDao(IRoleDao roleDao) {
		this.roleDao = roleDao;
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	
	
}

